package com.cheng.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cheng.admin.dao.DeliveryMapper;
import com.cheng.admin.model.Delivery;
import com.cheng.admin.model.Order;
import com.cheng.admin.service.DeliveryService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 快递 服务实现类
 * </p>
 *
 * @author 起凡
 * @since 2022-01-17
 */
@Service
public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> implements DeliveryService {

    @Override
    public void preprocess(Order order) {
        Delivery delivery = getById(order.getDeliveryId());
        order.setOriginPrice(order.getOriginPrice().add(delivery.getPrice()));
        order.setDeliveryPrice(delivery.getPrice());
    }

    @Override
    public void rollbackPreprocess(Order order) {

    }
}
